﻿using System.Collections.Generic;
using eCommerce.db.DALRespository;
using eCommerce.db.DataRespository;
using eCommerce.core.Helpers;
using System.Web;
using System;
using System.Web.Caching;

namespace eCommerce.db.BORespository
{
    public class PropertyBo
    {
        public static PropertyEntity GetById(int id)
        {
            return PropertyDal.GetById(id);
        }

        public static PropertyEntity GetByName(string name)
        {
            return PropertyDal.GetByName(name);
        }

        public static List<PropertyEntity> GetListByParentId(int parentId)
        {
            List<PropertyEntity> listProperTy = null;
            var cacheName = Utils.GET_PROPERTY_LISTBY_PARENTID(parentId);

            listProperTy = Utils.GetFromCacheIIS<List<PropertyEntity>>(cacheName);
            if (listProperTy == null)
            {
                listProperTy = PropertyDal.GetListByParentId(parentId);
                HttpContext.Current.Cache.Insert(cacheName, listProperTy, null, DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration);
            }
            return listProperTy;
        }

        public static List<PropertyEntity> GetListByParentIdName(int parentId, string searchType)
        {
            return PropertyDal.GetListByParentIdName(parentId, searchType);
        }
    }
}
